/**
 * Created by sdh on 2017/4/18.
 */
    var loginApp = angular.module('loginApp',[]);
    loginApp.controller('loginCtrl',function ($scope,$http) {
        $scope.processLoginForm = function (isVaild) {
            if(isVaild){
                //如果表单内容格式正确
                $http({
                    method:'POST',
                    url:'/login',
                    data:$.param($scope.loginFormData),
                    headers:{'Content-Type':'application/x-www-form-urlencoded'}
                }).success(function (data) {
                    if(data === 'success'){
                        alert('登录成功!');
                        window.location = '/';
                    } else {
                        alert(data);
                    }
                })
            } else {
                alert('输入有误！');
            }
        }
    });